<template>
    <span>{{addressView | fmt_address}}</span>
</template>

<script>
import addressKeyToViewLanguage, { getCountryKey } from '@src/component/common/BaseAddressSwitch/addressNameMultiLanguage';
import { getAddressData } from 'pub-bbx-utils';
export default {
    name: 'base-address-switch',
    props: {
        value: Object
    },

    data(){
        return {
            // 省市区key转换成对应语言的省市区
            addressView:{},
        }
    },

    watch: {
    
        value:{
            async handler(newVal,oldVal){

                if(newVal) {
                    let key = getCountryKey(newVal)

                    this.addressView = await addressKeyToViewLanguage(key, newVal);
                }
                
            },

            deep: true,
            immediate: true
        },
    },

    methods: {

    }
}
</script>